package com.zeus.activiti.web.action;

import com.opensymphony.xwork2.ActionSupport;
import com.zeus.activiti.web.activitiutil.ActivitiService;
import com.zeus.activiti.web.model.UserVO;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;

import java.util.Map;

/**
 * Created by Administrator on 2015/9/4.
 */
public class ProcessAction extends ActionSupport implements SessionAware,RequestAware{

    private ActivitiService activitiService;
    private Map<String,Object> request;
    private Map<String,Object> session;

    private String deploymentId;
    private String processDefinitionId;

    public String getDeploymentId() {
        return deploymentId;
    }

    public void setDeploymentId(String deploymentId) {
        this.deploymentId = deploymentId;
    }

    public String getProcessDefinitionId() {
        return processDefinitionId;
    }

    public void setProcessDefinitionId(String processDefinitionId) {
        this.processDefinitionId = processDefinitionId;
    }

    @Override
    public void setRequest(Map<String, Object> request) {
        this.request = request;
    }

    @Override
    public void setSession(Map<String, Object> session) {
        this.session = session;
    }

    public void setActivitiService(ActivitiService activitiService) {
        this.activitiService = activitiService;
    }

    /**
     * 列出所有的流程定义
     * @return
     */
    public String list(){
        request.put("processes",activitiService.getAllProcessDefinition());
        return "list";
    }

    public String delete(){
        return "delete";
    }

    public String start(){
        //processDefinitionId
        request.put("processDefinitionId",processDefinitionId);
        return "start";
    }

    /**
     * 获取用户的任务列表
     * @return
     */
    public String task(){
        UserVO userVO = (UserVO)session.get("user");
        //request.put("tasks",activitiService.getPersonalTask(session.get()));
        //request.put("tasks",activitiService.getPersonalTask(userVO.getUsername()));
        return "task";
    }
}
